<template>
  <div class="banner" @click="bannerShow">
    <swiper :options="swiperOption">
      <!-- slides -->
      <swiper-slide v-for="item of dataList" :id="item.id" :key="item.id" class="swiper-img">
        <img :src="item.src" alt />
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
      <div class="swiper-button-prev" slot="button-prev"></div>
      <div class="swiper-button-next" slot="button-next"></div>
    </swiper>
  </div>
</template>
<script>
export default {
  name: 'HomeSwiper',
  props: {
    swiper: Array
  },
  methods: {
   bannerShow () {
     this.$emit('bannerShow')
   }
  },
  data() {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        paginationType: 'fraction',
        observer: true,
        observeParents: true,
        loop: true,
        autoplay: 3000
      },
      dataList: [
        {
          id: '001',
          src:
            'https://img1.qunarzz.com/sight/p0/201309/24/977fea7b3c5cd758c8d65eac.jpg_600x330_0f80adad.jpg'
        },
        {
          id: '002',
          src:
            'https://img1.qunarzz.com/sight/p0/1505/b0/b0132e78efa00572.water.jpg_600x330_f29b56b1.jpg'
        }
      ]
    }
  }
}
</script>
<!-- Add 'scoped' attribute to limit CSS to this component only -->
<style scoped>
.swiper-img {
  width: 100%;
}
.swiper-img img {
  width: 100%;
}
.banner{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items:center;
  color: white

}
</style>
